<extend name="Public/base"/>

<block name="style">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
</block>

<block name="body">
    <div class="main-title">
        <h2>{:isset($info['id'])?'编辑':'新增'}广告位</h2>
    </div>
    <form action="{:U('saveAdvs')}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">广告名称</label>
            <div class="controls">
                <input type="text" class="text input-large" name="ad_name" value="{$info.ad_name|default=''}">
            </div>
        </div>

        <div class="form-item">
            <label class="item-label">分类</label>
            <div class="controls">
                <select name="pid" id="pid">
                    <volist name="position_list" id="vo">
                        <option value="{$vo.position_id}" <if condition="$info['pid'] eq $vo['position_id']">selected</if>>{$vo.position_name}</option>
                    </volist>
                </select>
            </div>
        </div>


         <div class="form-item">
            <label class="item-label">链接</label>
            <div class="controls">
                <input type="text" class="text input-large" name="ad_link" value="{$info.ad_link|default=''}">
            </div>
        </div>

         <div class="form-item">
            <label class="item-label">排序</label>
            <div class="controls">
                <input type="text" class="text input-large" name="orderby" value="{$info.orderby|default=''}">
            </div>
        </div>

        <div class="form-item">
            <label class="item-label">上传图片</label>
            <div class="controls">
                <input type="file" id="upload_good_img">
                <div class="upload-img-box">
                    <input type="hidden" name="thumb" id="thumb" value="{$info.thumb}"/>
                    <img id="thumb_img" src="__ROOT__{$info.thumb}"/>
                </div>
            </div>

            <script type="text/javascript">
                //上传图片
                /* 初始化上传插件 */
                $("#upload_good_img")
                    .uploadify(
                        {
                            "height" : 30,
                            "swf" : "__STATIC__/uploadify/uploadify.swf",
                            "fileObjName" : "download",
                            "buttonText" : "上传图片",
                            "uploader" : "{:U('File/upload',array('session_id'=>session_id()))}",
                            "width" : 100,
                            'removeTimeout' : 1,
                            'fileTypeExts' : '*.jpg; *.png; *.gif;',
                            "onUploadSuccess" : uploadPicture,
                            'onFallback' : function() {
                                alert('未检测到兼容版本的Flash.');
                            }
                        });
                function uploadPicture(file, data) {
                    var data = eval('('+data+')');
                    var src = '';
                    if (data.status) {
                        src = data.url || '__ROOT__' + data.url;
                        $("#thumb_img").attr('src',src);
                        $("#thumb").val(data.url);
                    } else {
                        layer.msg(data.info);
                    }
                }
            </script>
        </div>



        <div class="form-item">
            <input type="hidden" name="id" value="{$info.id|default=''}">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav("{:U('advs')}");
    
    </script>
</block>